//
//  HDRootNewsTopView.m
//  HDWuDaDaoServiceCenter
//
//  Created by HDNiuKuiming on 2017/4/10.
//  Copyright © 2017年 HDNiuKuiming. All rights reserved.
//

#import "HDRootNewsTopView.h"

@interface HDRootNewsTopView()<UIScrollViewDelegate>
@property (weak, nonatomic) IBOutlet UIPageControl *pageControl;

@end
@implementation HDRootNewsTopView

- (void)awakeFromNib {
    [super awakeFromNib];
    [self scrollViewInit];
}

- (void)scrollViewInit {
    _scrollView.contentSize = CGSizeMake(ScreenWidth, 160);
    _scrollView.pagingEnabled = YES;
    _scrollView.delegate = self;
}

- (void)resetPageCnt:(NSInteger)cnt {
    _pageControl.numberOfPages = cnt;
    
    if (cnt < 2)
        _pageControl.hidden = YES;
}

- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    NSInteger pageIndex = ceil(scrollView.contentOffset.x/ScreenWidth);
    _pageControl.currentPage = pageIndex;
}

@end
